// 1. 导入vue与vue-router
import Vue from 'vue';
import VueRouter from 'vue-router';


// 导入页面组件对象 >>> [懒加载]
const Home = () => import('views/home/Home.vue');
const Category = () => import('views/category/Category.vue');
const Cart = () => import('views/cart/Cart.vue');
const Profile = () => import('views/profile/Profile.vue');
const Detail = () => import('views/detail/Detail');

// 2. 安装插件
Vue.use(VueRouter);

const routes = [
  {
    path: '',
    // 重定向
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/category',
    component: Category
  },
  {
    path: '/cart',
    component: Cart
  },
  {
    path: '/profile',
    component: Profile
  },
  {
    path: '/detail',
    component: Detail
  }
]

// 3. 创建vue-router实例, 使用history模式
const router = new VueRouter({
  routes,
  mode: 'history'
})

// 4. 导出vue-router
export default router